/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package entity;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author Human Booster
 */
@Entity
@Table(name = "licence_customer")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "LicenceCustomer.findAll", query = "SELECT l FROM LicenceCustomer l"),
    @NamedQuery(name = "LicenceCustomer.findByLicenceSerial", query = "SELECT l FROM LicenceCustomer l WHERE l.licenceSerial = :licenceSerial"),
    @NamedQuery(name = "LicenceCustomer.findByCreationDate", query = "SELECT l FROM LicenceCustomer l WHERE l.creationDate = :creationDate"),
    @NamedQuery(name = "LicenceCustomer.findByLaunchCounter", query = "SELECT l FROM LicenceCustomer l WHERE l.launchCounter = :launchCounter")})
public class LicenceCustomer implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 45)
    @Column(name = "licence_serial")
    private String licenceSerial;
    @Basic(optional = false)
    @NotNull
    @Column(name = "creation_date")
    @Temporal(TemporalType.TIMESTAMP)
    private Date creationDate;
    @Basic(optional = false)
    @NotNull
    @Column(name = "launch_counter")
    private int launchCounter;
    @JoinColumn(name = "customer_id", referencedColumnName = "id")
    @ManyToOne(optional = false)
    private Customer customerId;
    @JoinColumn(name = "licence_software_id", referencedColumnName = "id")
    @ManyToOne(optional = false)
    private LicenceSoftware licenceSoftwareId;

    public LicenceCustomer() {
    }

    public LicenceCustomer(String licenceSerial) {
        this.licenceSerial = licenceSerial;
    }

    public LicenceCustomer(String licenceSerial, Date creationDate, int launchCounter) {
        this.licenceSerial = licenceSerial;
        this.creationDate = creationDate;
        this.launchCounter = launchCounter;
    }

    public String getLicenceSerial() {
        return licenceSerial;
    }

    public void setLicenceSerial(String licenceSerial) {
        this.licenceSerial = licenceSerial;
    }

    public Date getCreationDate() {
        return creationDate;
    }

    public void setCreationDate(Date creationDate) {
        this.creationDate = creationDate;
    }

    public int getLaunchCounter() {
        return launchCounter;
    }

    public void setLaunchCounter(int launchCounter) {
        this.launchCounter = launchCounter;
    }

    public Customer getCustomerId() {
        return customerId;
    }

    public void setCustomerId(Customer customerId) {
        this.customerId = customerId;
    }

    public LicenceSoftware getLicenceSoftwareId() {
        return licenceSoftwareId;
    }

    public void setLicenceSoftwareId(LicenceSoftware licenceSoftwareId) {
        this.licenceSoftwareId = licenceSoftwareId;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (licenceSerial != null ? licenceSerial.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof LicenceCustomer)) {
            return false;
        }
        LicenceCustomer other = (LicenceCustomer) object;
        if ((this.licenceSerial == null && other.licenceSerial != null) || (this.licenceSerial != null && !this.licenceSerial.equals(other.licenceSerial))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entity.LicenceCustomer[ licenceSerial=" + licenceSerial + " ]";
    }
    
}
